package com.coolxiaoyao.web.http;

import io.netty.handler.codec.http.EmptyHttpHeaders;
import io.netty.handler.codec.http.HttpHeaders;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * @author Kerry on 18/09/29
 */

public class HttpEntity<T> {
    public static final HttpEntity EMPTY = new HttpEntity();

    private final HttpHeaders headers;
    private final T body;

    public HttpEntity() {
        this(null, null);
    }

    public HttpEntity(T body) {
        this(null, body);
    }

    public HttpEntity(HttpHeaders headers, T body) {
        this.headers = headers;
        this.body = body;
    }

    @NotNull
    public HttpHeaders getHeaders() {
        if (this.headers == null) {
            return EmptyHttpHeaders.INSTANCE;
        }
        return headers;
    }

    @Nullable
    public T getBody() {
        return body;
    }
}
